<template>
  <div>
    <el-button @click="closeDrawer()" size="small" type="primary">导入模板下载</el-button>
    <div style="margin: 20px 0"></div>
    <importFile :title="'导入'" :actionUrl="`${uploadPrefix}/api/cmscloud.wholesales/orderDeliveryManage/import`" @close="closeHandler" />
    <div style="height: 47px"></div>
  </div>
</template>
<script>
import { excelTemplate } from '@/api/omSaleP/OrderManagement/PurchaseOrder/index.js';
import moment from 'moment';
import config from '@/assets/js/config';
import { exportExcelFile2 } from '@/utils';
export default {
  data() {
    return {
      uploadPrefix: config.uploadUrl, // 附件上传前缀
      fetchParams: {},
      fetchApi: () => {},
    };
  },
  methods: {
    closeDrawer(type) {
      this.$confirm('是否将Excel表格保存至本地文件夹?', '提示', {
        confirmButtonText: '下载',
        cancelButtonText: '取消',
        type: 'warning',
      })
        .then(() => {
          this.exportLoading = true;
          excelTemplate()
            .then((response) => {
              exportExcelFile2(response.data, '发运通知导入模板');
              this.exportLoading = false;
            })
            .catch((err) => {
              //console.log(err);
            });
        })
        .catch(() => {
          this.$message({
            type: 'info',
            message: '已取消',
          });
        });
    },
    closeHandler(val) {
      this.$emit('close');
    },
  },
};
</script>
